function fanHui0(){
   location = "reg.html"
}

var phoneReg = /^1[345789][0-9]{9}$/;
var pwdReg0= /^.{6,16}$/;
var pwdReg1 = /[0-9]+/;
var pwdReg2 = /[a-zA-Z]+/;
var pwdReg3 = /[=~!@#\$%\^&\*\(\)_\+\{\}\]:"\|',<?.\/\\]+/;
var isPhoneRight = false;
var isPwdRight = false;

phone.onkeyup = function(){
  var phoneValue = phone.value;
  if(!phoneReg.test(phoneValue)){
    phoneerror.innerHTML = "<img src = 'img/icon2.jpg' width='20px'/>";
    isPhoneRight = false;
  }else{
    phoneerror.innerHTML = "<img src = 'img/icon1.jpg' width='20px'/>";
    isPhoneRight = true;
  }
  checkAll();
};

pwd.onkeyup = function(){
  var pwdValue = pwd.value;
  var rightCount = 0;

  var lengthValid = pwdReg0.test(pwdValue);
  var numberValid = pwdReg1.test(pwdValue);
  var letterValid = pwdReg2.test(pwdValue);
  var symbolValid = pwdReg3.test(pwdValue);

  if(numberValid){
    rightCount++;
  }

  if(letterValid){
    rightCount++;
  }

  if(symbolValid){
    rightCount++;
  }

  if(!lengthValid||rightCount<2){
    pwderror.innerHTML = "<img src = 'img/icon2.jpg' width='20px'/>";
    isPwdRight = false;
  }else{
    pwderror.innerHTML = "<img src = 'img/icon1.jpg' width='20px'/>";
    isPwdRight = true;
  }
  checkAll();
};


function checkAll(){
  if(isPhoneRight&&isPwdRight){
    loginBtn.className = "loginBtn loginBtn_active";
  }else{
    loginBtn.className = "loginBtn";
  }
}

loginBtn.onclick = function(){
  if(this.className!="loginBtn"){
    loginBtn.value = "登录中";
    location.href = "index.html";
    $.post("http://test.hfjava.com/shop/userlogin",           $("form").serialize(),
           function(data){
             loginBtn.innerHTML = "登录";
             loginBtn.style.background = "";
             if(data=="false"){
		pwderror.innerHTML = "<img src = 'img/icon1.jpg' width='20px'/>";
             }else{
             	location.href = "index.html";
             }
	   }
          );
  }
};